/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EDT.actions;

import EDT.form.ConsultAllCrForm;
import EDT.obj.Calendrier;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author ali
 */
public class ConsultAllCrAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
   ConsultAllCrForm f = (ConsultAllCrForm) form;
        
        //Calendrier c = new Calendrier();
        //Appel à l'API
        
   
        int annee = EDT.api.API.getAnnee(f.getPromotion());
        Calendrier c = EDT.api.API.getAllCalendrierPromo(f.getKey(),f.getPromotion(), f.getPeriode(),f.getNbrperiode(),f.getGroupe());
        c.setTitre("Emplois du temps " +" "+f.getFormation()+"<br/>Promotion : "+annee+"/"+(annee+1)+"<br/>Groupe : "+f.getGroupe());
        
        
        request.setAttribute("calendrier", c.perideToTableHTMLClick("supression"));
        request.setAttribute("annee", annee);
        
        
        request.setAttribute("formation",f.getFormation());
        request.setAttribute("promo", f.getPromotion());
        request.setAttribute("periode", f.getPeriode());
        request.setAttribute("nbrPeriode", f.getNbrperiode());
        request.setAttribute("grp", f.getGroupe());
        
        return mapping.findForward("calendrierSelect");
        
      //  request.setAttribute("msg", f.toString());

        //return mapping.findForward("ajout");
        
    }
}
